<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 以数字开头
        // 以数字结尾
        // const reg = /^\d*$/
        // const reg = /^\d+$/
        //要就是没有数字,要就一个数字
        // const reg = /^\d?$/
        // const str1 = "abc"
        // const str2 = "123"
        // const str3 = "1ab"
        // const str4 = ""
        // const str5 = " "
        // const str6 = "&^%"
        // const str7 = "\n"
        // const str8 = "1"
        // console.log(reg.test(str1));
        // console.log(reg.test(str2));
        // console.log(reg.test(str3));
        // console.log(reg.test(str4));
        // console.log(reg.test(str5));
        // console.log(reg.test(str6));
        // console.log(reg.test(str7));
        // console.log(reg.test(str8));

        

        // const reg = /^\w\d{3}\w{3}$/
        const reg = /^\w\d+\w*$/
        const str1 = "a123abc"
        const str2 = "b123wdf"
        const str3 = "b123\n"
        const str4 = "b1233ae"
        const str5 = "b12efs1"
        const str6 = "b123fs13"
        console.log(reg.test(str1));//true
        console.log(reg.test(str2));//true
        console.log(reg.test(str3));//false
        console.log(reg.test(str4));//false/true
        console.log(reg.test(str5));//true
        console.log(reg.test(str6));//true
    </script>
</body>
</html>